Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = exports.jsonUrl = exports.json = exports.api = void 0;

var _util = _interopRequireDefault(require("../utils/util")), _config = _interopRequireDefault(require("../utils/config")), _util2 = _interopRequireDefault(require("../public/utils/util")), _request = require("../public/utils/request"), _apiGenerator = _interopRequireDefault(require("../public/utils/api-generator")), _host = require("../public/utils/host"), _apiInterceptors = require("../public/utils/api-interceptors");

function _interopRequireDefault(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function _objectSpread(t) {
    for (var e = 1; e < arguments.length; e++) {
        var o = null != arguments[e] ? arguments[e] : {}, r = Object.keys(o);
        "function" == typeof Object.getOwnPropertySymbols && (r = r.concat(Object.getOwnPropertySymbols(o).filter(function(e) {
            return Object.getOwnPropertyDescriptor(o, e).enumerable;
        }))), r.forEach(function(e) {
            _defineProperty(t, e, o[e]);
        });
    }
    return t;
}

function _defineProperty(e, t, o) {
    return t in e ? Object.defineProperty(e, t, {
        value: o,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = o, e;
}

var requestTimer = {}, requestTask = {}, requestLimit = function(e) {
    var t = "".concat(e.url).concat((e.url.includes("?") ? "&" : "?") + _util2.default.serialize(Object.assign({}, e.param || e.data || {})));
    if (requestTask[t]) return new Promise(function() {});
    var o = e.complete;
    return e.complete = function() {
        delete requestTask[t], clearTimeout(requestTimer[t]), "function" == typeof o && o.apply(void 0, arguments);
    }, requestTask[t] = Promise.resolve(e), requestTimer[t] = setTimeout(function() {
        delete requestTask[t], clearTimeout(requestTimer[t]);
    }, 5e3), requestTask[t];
}, requestIfNeedAccesstoekn = function(e) {
    return e.at ? (0, _apiInterceptors.requestAccesstoken)(e) : (0, _apiInterceptors.requestAccesstokenIfExist)(e);
}, requestUseLoading = function() {
    var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {};
    if (e.loading) {
        var t = "string" == typeof e.loading ? e.loading : "";
        wx.showLoading({
            mask: !0,
            title: t
        });
        var o = e.complete;
        e.complete = function() {
            wx.hideLoading(), "function" == typeof o && o.apply(void 0, arguments);
        };
    }
    return Promise.resolve(e);
}, requestUseUploadIfNeccesary = function(e) {
    var t = Promise.resolve(), o = e.name, r = e.filePath;
    return o && _util.default.isLocalFile(r) ? t = wx.fPromise("getFileInfo", {
        filePath: r
    }).then(function() {
        e.formData = Object.assign({}, e.formData || e.data || {}), e.method = "UPLOAD", 
        delete e.formData[o], console.log(JSON.stringify(e), "upload");
    }).catch(function() {
        e.data = e.formData || e.data || {}, e.data[o] = "";
    }) : e.data = e.formData || e.data || {}, t.then(function() {
        return e;
    });
}, responseHideLoading = function(e) {
    return wx.hideLoading(), Promise.resolve(e);
}, commonInterceptors = {
    requestInterceptors: [ _apiInterceptors.requestAccesstoken, requestUseUploadIfNeccesary ],
    responseInterceptors: [ _apiInterceptors.responseResolveOnlySuccess ]
};

_apiGenerator.default.interceptors.request([ requestLimit, requestUseLoading ]), 
_apiGenerator.default.interceptors.response(responseHideLoading);

var api = new _apiGenerator.default({
    weapp: {
        wxusermobile: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken,
            responseInterceptors: [ _apiInterceptors.responseResolveOnlySuccess ]
        } ],
        getdatafromscene: [ "GET" ],
        collectformid: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        addlike: [ "POST", commonInterceptors ],
        dellike: [ "POST", commonInterceptors ]
    },
    weappuser: {
        getuserauth: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ]
    },
    weappcard: {
        createv2: [ "POST", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken, requestUseUploadIfNeccesary ]
        } ],
        setfav: [ "POST", commonInterceptors ],
        view: [ "GET", {
            requestInterceptors: requestIfNeedAccesstoekn
        } ],
        showqrcode: [ "GET", commonInterceptors, {
            param: {
                app: _config.default.WX_APP_NAME
            }
        } ],
        search: [ "GET", commonInterceptors ],
        favlist: [ "GET", commonInterceptors ],
        favlistv2: [ "GET", commonInterceptors ],
        adorers: [ "GET", commonInterceptors ],
        history: [ "GET", commonInterceptors ],
        visitors: [ "GET", commonInterceptors ],
        collectors: [ "GET", commonInterceptors ],
        affections: [ "GET", commonInterceptors ],
        update: [ "POST", commonInterceptors ],
        sendh5cardmsg: [ "POST", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken, _apiInterceptors.requestSignature ]
        } ],
        showqrcodev3: [ "GET", commonInterceptors, {
            param: {
                app: _config.default.WX_APP_NAME
            }
        } ],
        checkprintcardemail: [ "GET", commonInterceptors ],
        setfavtop: [ "POST", commonInterceptors ],
        msgtip: [ "GET", commonInterceptors ],
        checkclaimcard: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        claim: [ "POST", commonInterceptors ],
        quitcreatecardnotify: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        batchsetfav: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        batchcreate: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        batchupdate: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        getcardforwardstylelist: [ "GET", commonInterceptors ],
        setcardforwardstyle: [ "POST", commonInterceptors ]
    },
    weappwallpaper: {
        create: [],
        list: [ "GET", commonInterceptors ]
    },
    swiftpass: {
        prepay: [ "POST", commonInterceptors, {
            param: {
                app: _config.default.WX_APP_NAME
            }
        } ],
        cancelorder: [ "POST", commonInterceptors, {
            param: {
                app: _config.default.WX_APP_NAME
            }
        } ]
    },
    qrcode: {
        printminicard: [ "GET", commonInterceptors, {
            param: {
                app: _config.default.WX_APP_NAME
            }
        } ],
        minicard: []
    },
    version: {
        lists: [ "GET", commonInterceptors ]
    },
    component: {
        minicardauthorizer: {
            showqrcode: []
        }
    }
}, _host.apiPrefix);

exports.api = api;

var minicardApi = new _apiGenerator.default({
    user: {
        checkissubscribe: [ "get", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        getuserspreadcounts: [ "get", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ]
    },
    card: {
        createclaim: [ "post", commonInterceptors ],
        updatemember: [ "post", commonInterceptors ],
        updatememberv2: [ "post", commonInterceptors ],
        getqyycard: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        view: [ "GET", {
            requestInterceptors: requestIfNeedAccesstoekn
        } ],
        viewv2: [ "GET", {
            requestInterceptors: requestIfNeedAccesstoekn
        } ],
        getleaveinfo: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ],
        getqrcodeurl: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ],
        viewmore: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ],
        delclaim: [ "post", commonInterceptors ],
        join: [ "post", commonInterceptors ],
        claim: [ "post", commonInterceptors ],
        checkishigher: [ "GET", commonInterceptors ],
        checkmobile: [ "post", commonInterceptors ],
        upload: [ "post", commonInterceptors ],
        delvoicesign: [ "post", commonInterceptors ],
        setsite: [ "post", commonInterceptors ],
        verifymobile: [ "post", commonInterceptors ],
        createvoicesignrecord: [ "post", commonInterceptors ],
        tagslists: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ],
        addtags: [ "post", commonInterceptors ],
        deltags: [ "post", commonInterceptors ],
        push: [ "post", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        pushcheck: [ "post", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        addlogs: [ "post", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ],
        getjoininfo: [ "get", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ],
        getadmindata: [ "GET", commonInterceptors ],
        applyjoin: [ "post", commonInterceptors ],
        samecompanylists: [ "GET", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken ]
        } ],
        getmore: [ "GET", commonInterceptors ],
        updatemore: [ "POST", commonInterceptors ],
        quit: [ "POST", commonInterceptors ],
        quitandtransfer: [ "POST", commonInterceptors ],
        sort: [ "POST", commonInterceptors ],
        rehab: [ "POST", commonInterceptors ],
        visitors: [ "GET", commonInterceptors ],
        favs: [ "GET", commonInterceptors ],
        likes: [ "GET", commonInterceptors ],
        viewbyuser: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        enhancefav: [ "POST", commonInterceptors ],
        togglereceive: [ "POST", commonInterceptors ],
        checkisexchangecard: [ "POST", commonInterceptors ],
        exchangecardv2: [ "POST", commonInterceptors ],
        exchangecardpush: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        addcolleagues: [ "POST", commonInterceptors ],
        getminicardgroupuserlist: [ "GET", commonInterceptors ],
        setminicardgroupuser: [ "POST", commonInterceptors ],
        getminicardgroupsiteuserlist: [ "GET", commonInterceptors ],
        setminicardgroupusersite: [ "POST", commonInterceptors ],
        setminicardmorelist: [ "POST", commonInterceptors ],
        setminicardgroupusermore: [ "POST", commonInterceptors ],
        getminicardgroupmoreuserlist: [ "GET", commonInterceptors ],
        getminicardmorelist: [ "GET", commonInterceptors ],
        exchangecardv3: [ "POST", commonInterceptors ],
        addexchangecardhistory: [ "POST", commonInterceptors ],
        getexchangecardhistorylist: [ "GET", commonInterceptors ]
    },
    sitetab: {
        update: [ "POST", commonInterceptors ],
        lists: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ]
    },
    manage: {
        amdinlists: [ "GET", commonInterceptors ],
        disband: [ "POST", commonInterceptors ],
        manageadmin: [ "POST", commonInterceptors ],
        searchadmin: [ "GET", commonInterceptors ],
        transfer: [ "POST", commonInterceptors ],
        transferbyagent: [ "POST", commonInterceptors ],
        transferapplylists: [ "GET", commonInterceptors ],
        addtransferapply: [ "POST", commonInterceptors ],
        searchmember: [ "GET", commonInterceptors ],
        applyjoinlists: [ "GET", commonInterceptors ],
        applyjoinmanage: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        setexpand: [ "POST", commonInterceptors ]
    },
    contact: {
        view: [ "GET", {
            requestInterceptors: requestIfNeedAccesstoekn
        } ],
        lists: [ "GET", commonInterceptors ],
        categorymemberlists: [ "GET", commonInterceptors ],
        changecorpname: [ "POST", commonInterceptors ],
        tryout: [ "POST", commonInterceptors ],
        tryoutv2: [ "POST", commonInterceptors ],
        searchmember: [ "GET", commonInterceptors ],
        corpnamelists: [ "GET", commonInterceptors ],
        isauthqywx: [ "GET", commonInterceptors ],
        getmemberdetail: [ "GET", commonInterceptors ],
        createtrialversion: [ "POST", commonInterceptors ]
    },
    category: {
        lists: [ "GET", commonInterceptors ],
        add: [ "POST", commonInterceptors ],
        del: [ "POST", commonInterceptors ],
        update: [ "POST", commonInterceptors ],
        moveuser: [ "POST", commonInterceptors ]
    },
    agent: {
        account: [ "GET", commonInterceptors ],
        clientlists: [ "GET", commonInterceptors ],
        accountlogs: [ "GET", commonInterceptors ],
        create: [ "post", commonInterceptors ],
        createv2: [ "post", commonInterceptors ],
        renew: [ "post", commonInterceptors ],
        renewv2: [ "post", commonInterceptors ],
        recharge: [ "post", commonInterceptors ],
        rechargev2: [ "post", commonInterceptors ],
        withdraw: [ "post", commonInterceptors ],
        addspreaduser: [ "post", commonInterceptors ],
        getspreadlogs: [ "get", commonInterceptors ],
        nopayclientlists: [ "GET", commonInterceptors ],
        getclientlogs: [ "GET", commonInterceptors ],
        getsitelists: [ "GET", commonInterceptors ],
        getsitelogs: [ "GET", commonInterceptors ],
        updatecompanyinfo: [ "post", commonInterceptors ]
    },
    agentmanage: {
        memberlists: [ "GET", commonInterceptors ],
        addmember: [ "post", commonInterceptors ],
        delmember: [ "post", commonInterceptors ]
    },
    pay: {
        getprice: [ "GET", commonInterceptors ],
        getpricev2: [ "GET", commonInterceptors ]
    },
    god: {
        searchcorp: [ "GET", commonInterceptors ],
        ishasmanageauth: [ "GET", commonInterceptors ],
        changecorp: [ "POST", commonInterceptors ]
    },
    goldgoods: {
        lists: [ "GET", commonInterceptors ],
        add: [ "POST", commonInterceptors ],
        del: [ "POST", commonInterceptors ],
        edit: [ "POST", commonInterceptors ],
        exchange: [ "POST", commonInterceptors ],
        exchangerecord: [ "GET", commonInterceptors ]
    },
    spread: {
        view: [ "GET", commonInterceptors ],
        lists: [ "GET", commonInterceptors ],
        task: [ "GET", commonInterceptors ],
        goldrecord: [ "GET", commonInterceptors ],
        apply: [ "POST", commonInterceptors ],
        addnewuserrecord: [ "POST", commonInterceptors ]
    },
    analysis: {
        count: [ "POST", commonInterceptors ],
        overview: [ "GET", commonInterceptors ],
        overviewv2: [ "GET", commonInterceptors ],
        rank: [ "GET", commonInterceptors ],
        userlists: [ "GET", commonInterceptors ],
        userlistsv2: [ "GET", commonInterceptors ],
        useroverview: [ "GET", commonInterceptors ],
        useroverviewv2: [ "GET", commonInterceptors ],
        userintelligentview: [ "GET", commonInterceptors ],
        userintelligentviewv2: [ "GET", commonInterceptors ],
        clientintelligentview: [ "GET", commonInterceptors ]
    },
    business: {
        lists: [ "GET", commonInterceptors ],
        view: [ "GET", commonInterceptors ],
        create: [ "POST", commonInterceptors ],
        update: [ "POST", commonInterceptors ],
        delete: [ "POST", commonInterceptors ],
        addlabel: [ "POST", commonInterceptors ],
        getlabel: [ "GET", commonInterceptors ],
        dellabel: [ "POST", commonInterceptors ],
        addfollow: [ "POST", commonInterceptors ],
        editfollow: [ "POST", commonInterceptors ],
        getfollow: [ "GET", commonInterceptors ],
        delfollow: [ "POST", commonInterceptors ],
        checkisinbusiness: [ "GET", commonInterceptors ],
        getcardbusinesslist: [ "GET", commonInterceptors ],
        transfer: [ "POST", commonInterceptors ]
    },
    businesslabel: {
        create: [ "POST", commonInterceptors ],
        delete: [ "POST", commonInterceptors ],
        relate: [ "POST", commonInterceptors ],
        view: [ "GET", commonInterceptors ]
    },
    miniapp: {
        delete: [ "POST", commonInterceptors ],
        lists: [ "GET", commonInterceptors ],
        postaudit: [ "POST", commonInterceptors ],
        upgradeversion: [ "POST", commonInterceptors ],
        updateinfo: [ "GET", commonInterceptors ],
        externalmemberlists: [ "GET", commonInterceptors ],
        delexternalmember: [ "POST", commonInterceptors ],
        addexternalmember: [ "POST", commonInterceptors ],
        relateuser: [ "POST", commonInterceptors ],
        toggleexternalmember: [ "POST", commonInterceptors ],
        updateexternalstyle: [ "POST", commonInterceptors ],
        updateappsetting: [ "POST", commonInterceptors ],
        getappsetting: [ "GET", commonInterceptors ]
    },
    auth: {
        toggleshowauthinfo: [ "POST", commonInterceptors ],
        getapplydetail: [ "GET", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken ]
        } ],
        createapply: [ "POST", commonInterceptors ],
        ocrbusinesslicence: [ "POST", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken, requestUseUploadIfNeccesary ]
        } ],
        getauthinfo: [ "GET", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken ]
        } ]
    },
    post: {
        lists: [ "GET", commonInterceptors ],
        upload: [ "POST", commonInterceptors ],
        record: [ "POST", commonInterceptors ],
        tick: [ "POST", commonInterceptors ],
        delete: [ "POST", commonInterceptors ]
    },
    activity: {
        getactivitylist: [ "GET", _objectSpread({
            alias: "lists"
        }, commonInterceptors) ],
        detail: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ],
        getactivityvisitmemberlist: [ "GET", _objectSpread({
            alias: "visitors"
        }, commonInterceptors) ],
        getactivityhandmemberlist: [ "GET", _objectSpread({
            alias: "members"
        }, commonInterceptors) ],
        create: [ "POST", commonInterceptors ],
        update: [ "POST", commonInterceptors ],
        sendcountexceltomail: [ "POST", _objectSpread({
            alias: "sendmail"
        }, commonInterceptors) ]
    },
    qrcode: {
        card: [],
        minicard: [],
        transfercover: [],
        activity: [ "GET", commonInterceptors ]
    },
    common: {
        createeventtracking: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstokenIfExist
        } ]
    }
}, _host.apiHost + "/minicard"), siteApi = new _apiGenerator.default({
    site: {
        search: [ "GET", commonInterceptors ],
        loginpc: [ "GET", commonInterceptors ],
        create: [ "POST", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken, requestUseUploadIfNeccesary ]
        } ],
        view: [ "GET", commonInterceptors ],
        checkorder: [ "GET", commonInterceptors ],
        calculateexpiretime: [ "POST", commonInterceptors ],
        renew: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        viewingsite: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ]
    },
    editor: {
        relatemodel: [ "GET", commonInterceptors ]
    },
    model: {
        getsiteexistmodelv2: [ "GET", commonInterceptors ]
    },
    bargain: {
        lists: [ "GET", commonInterceptors ]
    },
    nav: {
        getnavsformodel: [ "GET", commonInterceptors ]
    },
    manager: {
        lists: [ "GET", commonInterceptors ]
    },
    attachment: {
        lists: [ "GET", commonInterceptors ]
    },
    template: {
        getcategorylists: [ "GET", commonInterceptors ],
        gettemplatelists: [ "GET", commonInterceptors ],
        view: [ "GET", commonInterceptors ],
        usetemplate: [ "POST", commonInterceptors ]
    },
    profession: {
        detail: [ "GET", commonInterceptors ],
        minicardsitelists: [ "GET", commonInterceptors ]
    },
    agent: {
        info: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        checkwxverifynickname: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        historys: [ "GET", commonInterceptors ]
    }
}, _host.apiHost + "/site"), marketApi = new _apiGenerator.default({
    log: {
        lists: [ "GET", commonInterceptors ],
        timelists: [ "GET", commonInterceptors ],
        frequencylists: [ "GET", commonInterceptors ],
        userlists: [ "GET", commonInterceptors ],
        tickmsg: [ "GET", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ]
    },
    corp: {
        existmember: [ "GET", commonInterceptors ],
        join: [ "POST", {
            requestInterceptors: [ _apiInterceptors.requestAccesstoken ]
        } ],
        replacemobile: [ "POST", commonInterceptors ]
    }
}, _host.apiHost + "/market"), chatApi = new _apiGenerator.default({
    chat: {
        create: [ "POST", {
            requestInterceptors: _apiInterceptors.requestAccesstoken
        } ],
        lists: [ "GET", _objectSpread({
            alias: "chatlists"
        }, commonInterceptors) ],
        exitchat: [ "POST", commonInterceptors ]
    },
    message: {
        send: [ "POST", commonInterceptors ]
    },
    setting: {
        setchatinfo: [ "POST", commonInterceptors ]
    }
}, _host.apiHost + "/chat"), componentApi = new _apiGenerator.default({
    minicardauthorizer: {
        showqrcode: []
    }
}, _host.apiHost + "/component");

api.minicard = minicardApi, api.site = siteApi, api.market = marketApi, api.chat = chatApi, 
api.component = componentApi;

var ossPath = "https://oss.ibos.cn/common", json = {};

exports.json = json;

var jsonUrl = {
    styles: "".concat(ossPath, "/minicard/styles/style_v5.json"),
    previewInfo: "".concat(ossPath, "/json/card/previewInfo.json"),
    appLink: "".concat(ossPath, "/json/card/appLink.json"),
    vip: "".concat(ossPath, "/minicard/vip/vip_v3.json"),
    radar: "".concat(ossPath, "/json/radar/radarV1.json"),
    versions: "".concat(ossPath, "/json/site/versionsv3.json"),
    moreTemp: "".concat(ossPath, "/minicard/card/more-temp.json"),
    sports: "".concat(ossPath, "/minicard/mine/sports.json"),
    service: "".concat(ossPath, "/minicard/mine/service.json"),
    serviceList: "".concat(ossPath, "/minicard/serviceList.json"),
    getAllRegion: "".concat(ossPath, "/minicard/getAllRegion.json")
};

exports.jsonUrl = jsonUrl;

var FIVE_MILLISECONDS = 3e5;

Object.keys(jsonUrl).forEach(function(t) {
    return json[t] = function() {
        json[t] = json[t] || function() {};
        var e = Date.now();
        return (!json[t].time || e - json[t].time > FIVE_MILLISECONDS) && (json[t].time = e, 
        json[t].promise = (0, _request.get)("".concat(jsonUrl[t], "?timestamp=").concat(e)).catch(function() {
            return json[t].time = 0;
        })), json[t].promise;
    };
});

var _default = api;

exports.default = _default;